package o;

import android.annotation.TargetApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutInfo.Builder;
import android.content.pm.ShortcutManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build.VERSION;
import androidx.annotation.NonNull;
import com.huawei.appmarket.R;
import java.util.ArrayList;
import java.util.List;
import o.cxx.d;

public class exw {
    public static void ˎ(Context context, String str) {
        if (VERSION.SDK_INT < 26 || context == null || exv.ˊ(str) || !diu.ˊ().ˋ()) {
            Logger.ˎ("UpdateShortcutHelper", "updateCenterShortcut invalid");
            return;
        }
        exv.ˏ(str);
        ˊ(context);
        ˏ(context);
    }

    private static void ˊ(Context context) {
        ext o_ext = new ext();
        o_ext.ˊ((int) R.drawable.edu_center_icon);
        o_ext.ˎ(context.getString(R.string.educhannel_app_name));
        o_ext.ˊ("appmarket.eduCenter");
        o_ext.ˋ("com.huawei.eduCenter.intent.action.EduCenterActivity");
        ˊ(context, o_ext);
    }

    private static void ˏ(Context context) {
        ext o_ext = new ext();
        o_ext.ˊ((int) R.drawable.kids_center_icon);
        o_ext.ˎ(context.getString(R.string.kidschannel_app_name));
        o_ext.ˊ("appmarket.kidsCenter");
        o_ext.ˋ("com.huawei.kidsCenter.intent.action.KidsCenterActivity");
        ˊ(context, o_ext);
    }

    @TargetApi(26)
    private static void ˊ(Context context, ext o_ext) {
        ShortcutManager shortcutManager = (ShortcutManager) context.getSystemService(ShortcutManager.class);
        if (shortcutManager != null) {
            List arrayList = new ArrayList();
            arrayList.add(ˎ(context, ˋ(context, o_ext, null)));
            try {
                Logger.ˎ("UpdateShortcutHelper", "result: " + shortcutManager.updateShortcuts(arrayList));
            } catch (Exception e) {
                Logger.e("UpdateShortcutHelper", "update shortcut failed: " + e.toString());
            }
        }
    }

    @TargetApi(26)
    private static ShortcutInfo ˎ(@NonNull Context context, cxx o_cxx) {
        Builder builder = new Builder(context, o_cxx.ॱ());
        builder.setShortLabel(o_cxx.ˏ());
        if (o_cxx.ˊ() != null) {
            builder.setIcon(o_cxx.ˊ().ˋ());
        }
        if (o_cxx.ˎ() != null) {
            builder.setIntent(o_cxx.ˎ());
        }
        if (o_cxx.ˋ() != null) {
            builder.setActivity(o_cxx.ˋ());
        }
        return builder.build();
    }

    public static Intent ˏ(ext o_ext) {
        Intent intent = new Intent(o_ext.ʻ());
        intent.addCategory("android.intent.category.DEFAULT");
        intent.setPackage("com.huawei.appmarket");
        intent.putExtra("centeropenbyshortcut", true);
        intent.addFlags(268435456);
        return intent;
    }

    public static cxx ˋ(@NonNull Context context, ext o_ext, Class<?> cls) {
        Intent ˏ = ˏ(o_ext);
        if (cls != null) {
            ˏ.setComponent(new ComponentName(context, cls));
        }
        int dimension = (int) context.getResources().getDimension(17104896);
        return new d(o_ext.ˊ()).ˊ(ˏ).ˎ(o_ext.ॱ()).ˊ(cxz.ˏ(Bitmap.createScaledBitmap(BitmapFactory.decodeResource(context.getResources(), o_ext.ˎ()), dimension, dimension, false))).ˊ();
    }
}
